﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Cos.Core.Model.Template;
using Cos.Core.NHibernate;
using Cos.Core.NHibernate.Tests;
using NUnit.Framework;

namespace Cos.Module.Blog.NHibernate.Test
{
    public class ModuleFixtureBase : FixtureBase
    {
        public CultureDataModel culture;
        public BlogDataModel blog;

        public ModuleFixtureBase()
            : base(new TestModel())
        {
            this.culture = new CultureDataModel
            {
                Id = "fr-CA",
                CultureDesc = string.Empty,
                IsDefault = true
            };

            this.blog = new BlogDataModel
            {
                Articles = new List<ArticleDataModel>(),
                BlogCultures = new List<BlogCultureDataModel>(),
                BlogModerators = new List<BlogModeratorDataModel>(),
                BlogSuscribers = new List<BlogSubscriberDataModel>(),
                CreationDate = new DateTime(2011, 01, 06),
                OwnerFirstName = "owner first name",
                OwnerLastName = "owner last name",
                OwnerId = Guid.NewGuid()
            };

        }

        [TestFixtureSetUp]
        public void ModuleSetupContext()
        {
            using (var tx = this.Session.BeginTransaction())
            {
                this.Session.SaveOrUpdate(this.culture);
                this.Session.SaveOrUpdate(this.blog);

                tx.Commit();
            }

            this.Session.Flush();
            this.Session.Clear();
        }
    }
}
